<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<style>
.row input{
	margin-top: 5px;
}
.row select{
	margin-top: 5px;
}
</style>
<div class="form-horizontal" role="form" >
	<input type="hidden" id="token" name="token" value="<%=request.getAttribute("token") %>" />
    <input id="id" value="${member.id}"  type="hidden"/>
    <input id="xml" value="<fmt:formatDate value="${member.birthday}" type="both" pattern="yyyy-MM-dd HH:mm:ss" />"  type="hidden"/>
	<div class="form-group" style="margin-top:20px;">
 	    <label class="col-md-3 col-sm-3 control-label">昵称:</label>
        <div class="col-md-9">
<%--         	 <input id="nickName" value="${member.nickName}" data-check="require:true,code:input1,minlen:2,maxlen:20, message:2-20中文或字母" type="text" placeholder="昵称" class="form-control" name="nickName"/> --%>
        	 <input id="nickName" value="${member.nickName}"  data-check="require:true;code:^[a-zA-Z0-9\u4e00-\u9fa5]{1,30};message:不能为空" type="text" placeholder="昵称" class="form-control" name="nickName"/>
        </div>
    </div>
    
    
   	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">头像:</label>
        <div class="col-md-9">
        	 <div class="col-md-10">
	        	 <input class="fileInput" id="imageUploadify" type="file" name="file"  accept="image/*"/>
	        	 <div class="imageUploadify" id="logodiv">   
					<c:if test="${not empty(member.headImage)}">
						<img src="${member.headImage}" style="width: 60px;height: 60px">
					</c:if>
				 </div>
	        </div>
        </div>
      </div>
      <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">商家资质:</label>
        <div class="col-md-9">
        	 <div class="col-md-10">
	        	 <input class="fileInput" id="licenseUploadify" type="file" name="file"  accept="image/*"/>
	        	 <div class="imageUploadify" id="licensediv">   
					<c:if test="${not empty(member.cardImage)}">
					<c:forEach items="${fn:split(member.cardImage,',')}" var="i">
					    <div  style="width: 60px;float: left; margin-right: 5px;position: relative;" class="twoimgs"  onmouseout="javascript:$(this).find('.delimg').css('display','none')" onmousemove="javascript:$(this).find('.delimg').css('display','block')">
					          <img style=" height: 60px; width: 60px; " class="upimg" src="${i}">
					          <img style="width: 60px;position: absolute;top: 42px;display: none" class="delimg" src="${ctx}/static/img/picdel.png" onclick="javascript:$(this).parent().remove();" style="display: none;">
					    </div>
					</c:forEach>
					</c:if>
				 </div>
	        </div>
        </div>
      </div>
    	
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">真实姓名:</label>
        <div class="col-md-9">
        	 <input id="name" value="${member.name}"  data-check="require:true;code:^[a-zA-Z\u4e00-\u9fa5]{1,26};message:不能为空！" type="text" placeholder="真实姓名" class="form-control" name="nickName"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">生日:</label>
        <div class="col-md-9">
        	  <input id="saleTime" type="text" class="input-md form-control layer-date" placeholder="生日" value="<fmt:formatDate value="${member.birthday}" type="both" pattern="yyyy-MM-dd" />" name="saleTime">
        	                                                       
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">行业:</label>
        <div class="col-md-9">
        	<select id="typeId" placeholder="选择分类" class="chosen-select full-width" tabindex="4">
			</select>
        </div>
    </div>
    
    
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">手机号:</label>
        <div class="col-md-9">
        	 <input id="mobile" value="${member.mobile}" data-check="require:true;code:^[0-9]{1,30};message:不能为空!" type="text" placeholder="手机号" class="form-control" name="nickName"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">身份证号:</label>
        <div class="col-md-9">
        	 <input id="cardNo" value="${member.cardNo}" data-check="require:true;code:^[a-zA-Z0-9]{1,26};message:不能为空" type="text" placeholder="身份证号码" class="form-control" name="nickName"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">用户类型:</label>
        <div class="col-md-9">
        	  <select data-placeholder="用户类型" id="type" class="input-md form-control chosen-select layer-date" tabindex="4" name="saleTimeS">
                  <option value="0">手机用户</option>
                  <option value="1">第三方用户</option>
              </select>
        </div>
    </div>
    
    


</div>

<script>

$(function(){
	jQuery.checkall(false);
})
$(function(){
	var saleTime = {
        elem: "#saleTime",
        format: "YYYY-MM-DD",
        istime: true,
        istoday: true,
        choose: function(datas) {
        }
    };
    laydate(saleTime);
})

var typeId="${departmentId}";
$("#typeId").chosen({ width: '100%' });

$.ajax({  
	url:'${ctx}/merchantType/list',  		 					
	data:{						
	},   
	type: 'POST',
	dataType:'json',  
	success:function(response){
		if(response.code==0){
			var html=[];
			var data=response.data||[];
			for(var i=0;i<data.length;i++){
				html.push('<option value="'+data[i].id+'" ');
				html.push('>'+data[i].name+'</option>');
			}
			$("#typeId").append(html.join(""));
			$("#typeId").trigger("chosen:updated");
		}
	}  
 });
 


$("#imageUploadify").uploadify({
	'buttonImage':'${ctx}/static/js/plugins/uploadify/uploadify-button.png',
    'swf': '${ctx}/static/js/plugins/uploadify/uploadify.swf',
    'uploader':'${ctx}/file/uploadOss',
    "multi":false,
    'onFallback' : function() {//检测FLASH失败调用 
    	alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");  
    },  
    'onUploadSuccess':function(file, data, response){
    	var jData = jQuery.parseJSON(data);
        $("#logodiv").html("<img src=\""+jData.data+"\" style=\"width: 60px;height: 60px;padding-left:5px;\">");
	}
});

$("#licenseUploadify").uploadify({
	'buttonImage':'${ctx}/static/js/plugins/uploadify/uploadify-button.png',
    'swf': '${ctx}/static/js/plugins/uploadify/uploadify.swf',
    'uploader':'${ctx}/file/uploadOss',
    "multi":false,
    'onFallback' : function() {//检测FLASH失败调用 
    	alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");  
    },  
    'onUploadSuccess':function(file, data, response){
    	var jData = jQuery.parseJSON(data);
        var html=" <div  style=\"width: 60px;float: left; margin-right: 5px;position: relative;\" class=\"twoimgs\"  onmouseout=\"javascript:$(this).find('.delimg').css('display','none')\" onmousemove=\"javascript:$(this).find('.delimg').css('display','block')\">";
        html+=" <img style=\" height: 60px; width: 60px; \" class=\"upimg\" src=\'"+jData.data+"'\">";
        html+="<img style=\"width: 60px;position: absolute;top: 42px;display:none\" class=\"delimg\" src=\"${ctx}/static/img/picdel.png\" onclick=\"javascript:$(this).parent().remove();\" style=\"display: none;\"></div>";

    $("#licensediv").append(html);
	}
});
</script>